﻿using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using DB;
using System.Data;
using System.Text;
using System.Data.SqlClient;

public class ConditionGetter : IConditionGetter
{
    DataAccess da = new DataAccess();

    public string getCourseByTermStd(string yterm, string stdid)
    {
        string year = yterm.Substring(0, 4);
        string term = yterm.Substring(4, 1).Equals("上") ? "0" : "1";
        string sql_sql = "exec conditon_getCourseByTermStd " + year + "," + term + "," + stdid;
        return JsonConvertor.getJsonTable(sql_sql);
    }

    public string getProsBySchool(string schoolid)
    {
        string sql_sql = "exec conditon_getProsBySchool " + schoolid;
        StringBuilder data_back = new StringBuilder();
        DataTable dt = da.GetTable(sql_sql);
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            data_back.Append(dt.Rows[i][1]);
        }
        return data_back.ToString();
    }

    public string getExzamByCourse(string courseid)
    {
        string sql_sql = "exec conditon_getExzamByCourse " + courseid;
        return JsonConvertor.getJsonTable(sql_sql);
    }

    public string getCourseByTechTerm(string techid, string yterm)
    {
        string year = yterm.Substring(0, 4);
        string term = yterm.Substring(4, 1).Equals("上") ? "0" : "1";
        string sql_sql = "exec conditon_getCourseByTechTerm " + techid + "," + year + "," + term;
        return JsonConvertor.getJsonTable(sql_sql);
    }

    public string getExzamtype()
    {
        string sql_sql = "exec conditon_getExzamtype ";
        return JsonConvertor.getJsonTable(sql_sql);
    }
    public string getExzamByCourseTech(string techid, string courseid)
    {
        string sql_sql = "exec exzam_getExzamByCourseTech " + courseid ;
        return JsonConvertor.getJsonTable(sql_sql);
    }

}
